import { lib, game, ui, get, ai, _status } from "../../noname.js";
game.import("extension",function(){
	return {name:"至尊包",content:function(config,pack){
    
},precontent:function(){
    
},help:{},config:{},package:{
    character: {
        character: {
            "imp_jiangwei": ["male","shen","2/5/6",["olsbzhuri","jiufa","tianren","pingxiang","imps_ranji"],["des:术奉武侯来","ext:至尊包/imp_jiangwei.jpg","die:ext:至尊包/audio/die/imp_jiangwei.mp3"]],
            "imp_shizuru": ["female","shen","5/5/3",["imps_nianli","imps_benzhan"],["forbidai","des:Rewrite","ext:至尊包/imp_shizuru.jpg","die:ext:至尊包/audio/die/imp_shizuru.mp3"]],
            "imp_shiki": ["female","shen","4/6/3",["imps_yujie"],["forbidai","des:Summer Pockets","ext:至尊包/imp_shiki.jpg","die:ext:至尊包/audio/die/imp_shiki.mp3"]],
            "imp_zhaoxiang": ["female","shu","5/5/3",["imps_fuhan","refanghun"],["forbidai","ext:至尊包/imp_zhaoxiang.jpg","die:ext:至尊包/audio/die/imp_zhaoxiang.mp3"]],
            "imp_caojinyu": ["female","wei","5/5/3",["imps_yuqi","imps_shanshen","imps_xianjing"],["forbidai","des:独掌牌堆众神主","ext:至尊包/imp_caojinyu.jpg","die:ext:至尊包/audio/die/imp_caojinyu.mp3"]],
            "imp_zhangjiao": ["male","qun","5/5/3",["xinleiji","xinguidao","xinhuangtian","reqingguo","reluoshen"],["forbidai","des:以雷霆之力击碎黑暗","ext:至尊包/imp_zhangjiao.jpg","die:ext:至尊包/audio/die/imp_zhangjiao.mp3"]],
            "imp_zhangfen": ["male","wu","5/5/3",["miniwanglu","minixianzhu","minichaixie","miniwushuang","imps_qicai"],["forbidai","des:大奋车来咯！","ext:至尊包/imp_zhangfen.jpg","die:ext:至尊包/audio/die/imp_zhangfen.mp3"]],
            "imp_zhenji": ["female","wei","5/5/3",["miniqixian","minifeifu","imps_shenfu","minisanyao","rezhiman"],["forbidai","des:荣曜秋菊，华茂春松。","ext:至尊包/imp_zhenji.jpg","die:ext:至尊包/audio/die/imp_zhenji.mp3"]],
            "imp_guozhao": ["female","shu","5/5/3",["jsrgpianchong","jsrgzunwei","minixiaoguo","miniguzheng","imps_qiwu","imps_jujian"],["forbidai","des:超模的摸牌怪","ext:至尊包/imp_guozhao.jpg","die:ext:至尊包/audio/die/imp_guozhao.mp3"]],
            "imp_saimiuer": ["male","shu","5/5/3",["sksn_fanji","sksn_caijue","imps_fengzi","imps_jizhan","zhiheng"],["des:上帝的忠将","ext:至尊包/imp_saimiuer.jpg","die:ext:至尊包/audio/die/imp_saimiuer.mp3"]],
            "imp_illya": ["female","shen","4/6/3",["imps_yujie"],["forbidai","des:Fate/Kaleid Liner","ext:至尊包/imp_illya.jpg","die:ext:至尊包/audio/die/imp_illya.mp3"]],
            "imp_kamome": ["female","shu","5/5/3",["kamome_huanmeng","imps_yangfan","imps_jieban","imps_qicai"],["des:Summer Pockets","ext:至尊包/imp_kamome.jpg","die:ext:至尊包/audio/die/imp_kamome.mp3"]],
            "imp_xintianbuzhi": ["female","SK_qun","5/5/3",["sksn_yineng","spysz","pytianjiang","dccaisi"],["forbidai","des:异能持有者","ext:至尊包/imp_xintianbuzhi.jpg","die:ext:至尊包/audio/die/imp_xintianbuzhi.mp3"]],
            "imp_shiori": ["female","wu","5/5/2",["shiori_huijuan","minisbliegong","twgongji","minireqieting","imps_hengwu"],["forbidai","des:Kanon","ext:至尊包/imp_shiori.jpg","die:ext:至尊包/audio/die/imp_shiori.mp3"]],
            "imp_wolier": ["male","qun","5/5/2",["sksn_shenian","sksn_shihun","minifuhun","xinwangxi","satomi_luodao"],["des:使徒","ext:至尊包/imp_wolier.jpg","die:ext:至尊包/audio/die/imp_wolier.mp3"]],
        },
        translate: {
            "imp_jiangwei": "尊姜维",
            "imp_shizuru": "尊中津静流",
            "imp_shiki": "尊神山识",
            "imp_zhaoxiang": "尊赵襄",
            "imp_caojinyu": "尊曹金玉",
            "imp_zhangjiao": "尊张角",
            "imp_zhangfen": "尊张奋",
            "imp_zhenji": "尊甄姬",
            "imp_guozhao": "尊郭照",
            "至尊包": "至尊包",
            "imp_saimiuer": "尊塞缪尔",
            "imp_illya": "尊伊莉雅",
            "imp_kamome": "尊久岛鸥",
            "imp_xintianbuzhi": "尊新田布止",
            "imp_shiori": "尊美坂栞",
            "imp_wolier": "尊沃里尔",
        },
    },
    card: {
        card: {
            "impc_railgun": {
                fullskin: true,
                derivation: "puyuan",
                cardcolor: "diamond",
                type: "equip",
                subtype: "equip1",
                distance: {
                    attackFrom: -8,
                },
                skills: ["impc_railgun_skill"],
                onDestroy(card) {
                    if (_status.pyzhuren && _status.pyzhuren[card.name]) {
                        delete _status.pyzhuren[card.name];
                    }
                },
                ai: {
                    basic: {
                        equipValue: 3,
                        order: (card, player) => {
                            const equipValue = get.equipValue(card, player) / 20;
                            return player && player.hasSkillTag("reverseEquip") ? 8.5 - equipValue : 8 + equipValue;
                        },
                        useful: 2,
                        value: (card, player, index, method) => {
                            if (!player.getCards("e").includes(card) && !player.canEquip(card, true)) return 0.01;
                            const info = get.info(card),
                                current = player.getEquip(info.subtype),
                                value = current && card != current && get.value(current, player);
                            let equipValue = info.ai.equipValue || info.ai.basic.equipValue;
                            if (typeof equipValue == "function") {
                                if (method == "raw") return equipValue(card, player);
                                if (method == "raw2") return equipValue(card, player) - value;
                                return Math.max(0.1, equipValue(card, player) - value);
                            }
                            if (typeof equipValue != "number") equipValue = 0;
                            if (method == "raw") return equipValue;
                            if (method == "raw2") return equipValue - value;
                            return Math.max(0.1, equipValue - value);
                        },
                    },
                    result: {
                        target: (player, target, card) => get.equipResult(player, target, card),
                    },
                },
                enable: true,
                selectTarget: -1,
                filterTarget: (card, player, target) => player == target && target.canEquip(card, true),
                modTarget: true,
                allowMultiple: false,
                content: function () {
                    if (
                        !card?.cards.some(card => {
                            return get.position(card, true) !== "o";
                        })
                    ) {
                        target.equip(card);
                    }
                    //if (cards.length && get.position(cards[0], true) == "o") target.equip(cards[0]);
                },
                toself: true,
                image: "ext:至尊包/impc_railgun.png",
            },
            "impc_KochiyaReidaisai": {
                audio: "gezi_reidaisai",
                fullskin: true,
                type: "trick",
                enable: true,
				chongzhu: true,
                selectTarget: -1,
                filterTarget: function (card,player,target){
					function inHumanSide(target, player){
						if(target == player || target.isUnderControl()) return true;
						if(get.mode() == 'guozhan'){
							return [target.getGuozhanGroup(0), target.getGuozhanGroup(1)]
								.some(t => 
									[player.getGuozhanGroup(0), player.getGuozhanGroup(1)].includes(t)
								);
						}
						if(get.mode() != 'identity') return !target.isEnemyOf(player);
						if(get.mode() == 'identity'){
							if(['zhu','zhong'].includes(player.identity)) return ['zhu','zhong'].includes(target.identity);
							if(player.identity == 'fan') return (target.identity == 'fan');
							return false;
						}
					}
					return inHumanSide(target, player);
                },
                content: function (){
                    'step 0'
                    target.draw(2);
                    target.chooseCardTarget({
                        selectCard:[1,2],
                        position:'he',
                        filterTarget: function (card, player, target) {
                            return player != target;
                        },
                        ai1:function(card){
							if(card.type == 'equip'){
								if(get.subtype(card, false) == "equip1" || get.subtype(card, false) == "equip4"){
									return 1;
								} else {
									return 2;
								}
							} else {
								return get.unuseful(card) + 3;
							}                            
                        },
                        ai2:function(target){
                            return ai.get.attitude(_status.event.player,target);
                        },
                        prompt:'你送给别人一到两张牌!'
                    });
                    'step 1'
                    if(result.targets&&result.targets[0]){
                        result.targets[0].gain(result.cards); 
                        target.$give(result.cards.length, result.targets[0]);
                        //target.addExpose();
                    }
                },
                ai: {
                    wuxie: function (target,card,player,viewer){
                        if (game.countPlayer(function(current){
                            return ai.get.attitude(viewer,current)<=0;
                        }) == 1){
                            return 0;
                        };
                        if (ai.get.attitude(viewer,target)<=0 && target.countCards('e',function(card){
                            return get.value(card) > 0;    
                        })){
                            if(Math.random()<0.5) return 0;
                            return 1;
                        }
                        return 0; 
                    },
                    basic: {
                        order: 5,
                        useful: 1,
                        value: 1,
                    },
                    result: {
                        target: function (player,target){
                            return 1;
                        },
                    },
                    tag: {
                        multitarget: 1,
                    },
                },
                image: "ext:至尊包/impc_KochiyaReidaisai.png",
            },
        },
        translate: {
            "impc_railgun": "高斯轨道炮",
            "impc_railgun_info": "锁定技，你使用【杀】次数限制+15。当你使用【杀】对目标角色造成伤害时，你可以弃置一张牌，令此伤害+3。",
            "至尊包": "至尊包",
            "impc_KochiyaReidaisai": "界守矢祭",
            "impc_KochiyaReidaisai_info": "出牌阶段，对所有己方角色使用：目标各摸两张牌，然后可以交给一名其它角色一到两张牌。",
        },
        list: [],
    },
    skill: {
        skill: {
            "impc_railgun_skill": {
                audio: "ext:至尊包:1",
                trigger: {
                    source: "damageBegin1",
                },
                direct: true,
                equipSkill: true,
                mod: {
                    cardUsable: function (card, player, num) {
                        var cardx = player.getEquip("impc_railgun");
                        if (card.name == "sha" && (!cardx || player.hasSkill("impc_railgun_skill", null, false) || (!_status.pyzhuren_diamond_temp && !ui.selected.cards.includes(cardx)))) {
                            return num + 15;
                        }
                    },
                    "cardEnabled2": function (card, player) {
                        if (!_status.event.addCount_extra || player.hasSkill("impc_railgun_skill", null, false)) return;
                        if (card && card == player.getEquip("impc_railgun")) {
                            _status.pyzhuren_diamond_temp = true;
                            var bool = lib.filter.cardUsable(get.autoViewAs({ name: "sha" }, ui.selected.cards.concat([card])), player);
                            delete _status.pyzhuren_diamond_temp;
                            if (!bool) return false;
                        }
                    },
                },
                filter: function (event, player) {
                    if (event.getParent().name != "sha") return false;
                    return (
                        player.countCards("he", function (card) {
                            return card != player.getEquip("impc_railgun");
                        }) > 0
                    );
                },
                content: function () {
                    "step 0";
                    var next = player.chooseToDiscard(
                        "he",
                        function (card, player) {
                            return card != player.getEquip("impc_railgun");
                        },
                        get.prompt(event.name, trigger.player),
                        "弃置一张牌，令即将对其造成的伤害+3"
                    );
                    next.set("target", trigger.player);
                    next.ai = function (card) {
                        if (_status.event.goon) return 30 / (1 + _status.event.target.hp) - get.value(card);
                        return -1;
                    };
                    next.set(
                        "goon",
                        get.attitude(player, trigger.player) < 0 &&
                            !trigger.player.hasSkillTag("filterDamage", null, {
                                player: player,
                                card: trigger.card,
                            }) &&
                            get.damageEffect(trigger.player, player, player, get.natureList(trigger)) > 0
                    );
                    next.logSkill = [event.name, trigger.player];
                    "step 1";
                    if (result.bool) trigger.num += 3;
                    else player.storage.counttrigger.pyzhuren_diamond--;
                },
                ai: {
                    expose: 0.25,
                    equipValue: function (card, player) {
                        return Math.min(7, 3.6 + player.countCards("h") / 2);
                    },
                    basic: {
                        equipValue: 4.5,
                    },
                },
                "_priority": -25,
            },
            "imps_ranji": {
                audio: "ext:至尊包:2",
                trigger: {
                    player: "phaseJieshuBegin",
                },
                "prompt2": function (event, player) {
                    var str = "获得技能";
                    var num = lib.skill.olsbranji.getNum(player);
                    if (num >= player.getHp() - 1) str += "【困奋】";
                    if (Math.abs(num - player.getHp()) <= 1) str += "和";
                    if (num <= player.getHp() + 1) str += "【诈降】";
                    str += "，然后";
                    var num1 = player.countCards("h") - player.getHandcardLimit();
                    if (num1 || player.isDamaged()) {
                        if (num1)
                            str +=
                                num1 < 0
                                    ? "摸" + get.cnNumber(-num1) + "张牌"
                                    : "弃置" + get.cnNumber(num1) + "张牌";
                        if (num1 && player.isDamaged()) str += "或";
                        if (player.isDamaged()) str += "回复" + player.getDamagedHp() + "点体力";
                        str += "，最后";
                    }
                    str += "你不能回复体力直到你杀死角色。";
                    return str;
                },
                check: function (event, player) {
                    var num = lib.skill.olsbranji.getNum(player);
                    if (Math.abs(num - player.getHp()) <= 1) return true;
                    return (
                        player.getHandcardLimit() - player.countCards("h") >= 3 || player.getDamagedHp() >= 2
                    );
                },
                limited: true,
                skillAnimation: true,
                animationColor: "fire",
                content: function* (event, map) {
                    var player = map.player;
                    var trigger = map.trigger;
                    player.awakenSkill("imps_ranji");
                    var num = lib.skill.olsbranji.getNum(player);
                    const skills = [];
                    if (num >= player.getHp() - 1) {
                        skills.push("kunfen");
                        player.storage.kunfen = true;
                    }
                    if (num <= player.getHp() + 1) skills.push("zhaxiang");
                    player.addSkills(skills);
                    if (player.countCards("h") != player.getHandcardLimit() || player.isDamaged()) {
                        var result,
                            num1 = player.countCards("h") - player.getHandcardLimit();
                        if (!num1) result = { index: 1 };
                        else if (player.isHealthy()) result = { index: 0 };
                        else {
                            result = yield player
                                .chooseControl("手牌数", "体力值")
                                .set("choiceList", [
                                    num1 < 0
                                        ? "摸" + get.cnNumber(-num1) + "张牌"
                                        : "弃置" + get.cnNumber(num1) + "张牌",
                                    "回复" + player.getDamagedHp() + "点体力",
                                ])
                                .set("ai", () => {
                                    var player = _status.event.player;
                                    var list = _status.event.list;
                                    var num1 = get.effect(player, { name: "draw" }, player, player);
                                    var num2 = get.recoverEffect(player, player, player);
                                    return num1 * list[0] > num2 * list[1] ? 0 : 1;
                                })
                                .set("list", [-num1, player.getDamagedHp()]);
                        }
                        if (result.index == 0) {
                            if (num1 < 0) yield player.drawTo(player.getHandcardLimit());
                            else yield player.chooseToDiscard(num1, "h", true);
                        } else {
                            yield player.recover(player.maxHp - player.hp);
                        }
                    }
                    player.addSkill("olsbranji_norecover");
                    player.when({ source: "dieAfter" }).then(() => player.removeSkill("olsbranji_norecover"));
                },
                derivation: ["kunfenx","zhaxiang"],
                getList: function (event) {
                    return event.getParent().phaseList.map((list) => list.split("|")[0]);
                },
                getNum: function (player) {
                    return player
                        .getHistory("useCard", (evt) => {
                            return lib.phaseName.some((name) => {
                                return evt.getParent(name).name == name;
                            });
                        })
                        .reduce((list, evt) => {
                            return list.add(
                                evt.getParent(lib.phaseName.find((name) => evt.getParent(name).name == name))
                            );
                        }, []).length;
                },
                subSkill: {
                    norecover: {
                        charlotte: true,
                        mark: true,
                        intro: {
                            content: "不能回复体力",
                        },
                        trigger: {
                            player: "recoverBefore",
                        },
                        forced: true,
                        firstDo: true,
                        content: function () {
                            trigger.cancel();
                        },
                        ai: {
                            effect: {
                                target: function (card, player, target) {
                                    if (get.tag(card, "recover")) return "zeroplayertarget";
                                },
                            },
                        },
                        sub: true,
                        "_priority": 0,
                        sourceSkill: "燃己",
                    },
                },
                mark: true,
                intro: {
                    content: "limited",
                },
                init: (player, skill) => (player.storage[skill] = false),
                "_priority": 0,
            },
            "imps_nianli": {
                enable: "chooseToUse",
                charlotte: true,
                prompt: "展示一张♦/♣/♥/♠手牌，然后视为使用一张雷杀/闪/桃/无懈可击",
                usable: 3,
                viewAs(cards,player){
                    var name=false;
                    var nature=null;
                    switch(get.suit(cards[0],player)){
                        case 'club':name='shan';break;
                        case 'diamond':name='sha';nature='thunder';break;
                        case 'spade':name='wuxie';break;
                        case 'heart':name='tao';break;
                    }
                    if(name) return {name:name,nature:nature,isCard:true};
                    return null;
                },
                check(card){
                    var player=_status.event.player;
                    if(_status.event.type=='phase'){
                        var max=0;
                        var name2;
                        var list=['sha','tao'];
                        var map={sha:'diamond',tao:'heart'}
                        for(var i=0;i<list.length;i++){
                            var name=list[i];
                            if(player.countCards('h',function(card){
                                return get.suit(card,player)==map[name];
                            })>0&&player.getUseValue({name:name,nature:name=='sha'?'fire':null})>0){
                                var temp=get.order({name:name,nature:name=='sha'?'fire':null});
                                if(temp>max){
                                    max=temp;
                                    name2=map[name];
                                }
                            }
                        }
                        if(name2==get.suit(card,player)) return 1;
                        return 0;
                    }
                    return 1;
                },
                ignoreMod: true,
                filterCard(card,player,event){
                    event=event||_status.event;
                    var filter=event._backup.filterCard;
                    var name=get.suit(card,player);
                    if(name=='club'&&filter({name:'shan'},player,event)) return true;
                    if(name=='diamond'&&filter({name:'sha',nature:'thunder'},player,event)) return true;
                    if(name=='spade'&&filter({name:'wuxie'},player,event)) return true;
                    if(name=='heart'&&filter({name:'tao'},player,event)) return true;
                    return false;
                },
                filter(event,player){
                    //if(player.hasSkill('shizuru_nianli_round')) return true;
                    var filter=event.filterCard;
                    if(filter({name:'sha',nature:'thunder'},player,event)&&player.countCards('h',{suit:'diamond'})) return true;
                    if(filter({name:'shan'},player,event)&&player.countCards('h',{suit:'club'})) return true;
                    if(filter({name:'tao'},player,event)&&player.countCards('h',{suit:'heart'})) return true;
                    if(filter({name:'wuxie'},player,event)&&player.countCards('h',{suit:'spade'})) return true;
                    return false;
                },
                precontent(){
                    player.logSkill('shizuru_nianli');
                    //player.addTempSkill('shizuru_nianli_round','roundStart');
                    player.showCards(get.translation(player)+'发动了【念力】',event.result.cards.slice(0));
                    event.result.card.cards=[];
                    event.result.cards=[];
                    delete event.result.skill;
                    delete event.result.card.suit;
                    delete event.result.card.number;
                    event.getParent().addCount=false;
                    event.getParent().shizuru_nianli=false;
                },
                ai: {
                    respondSha: true,
                    respondShan: true,
                    skillTagFilter(player,tag){
                        //if(player.hasSkill('shizuru_nianli_round')) return false;
                        var name;
                        switch(tag){
                            case 'respondSha':name='diamond';break;
                            case 'respondShan':name='club';break;
                            case 'save':name='heart';break;
                        }
                        if(!player.countCards('h',{suit:name})) return false;
                    },
                    order(item,player){
                        if(player&&_status.event.type=='phase'){
                            var max=0;
                            var list=['sha','tao'];
                            var map={sha:'diamond',tao:'heart'}
                            for(var i=0;i<list.length;i++){
                                var name=list[i];
                                if(player.countCards('h',function(card){
                                    return get.suit(card,player)==map[name];
                                })>0&&player.getUseValue({name:name,nature:name=='sha'?'thunder':null})>0){
                                    var temp=get.order({name:name,nature:name=='sha'?'thunder':null});
                                    if(temp>max) max=temp;
                                }
                            }
                            max/=1.1;
                            return max;
                        }
                        return 2;
                    },
                },
                hiddenCard(player,name){
                    if(name=='wuxie') return player.countCards('h',function(card){
                        return _status.connectMode||get.suit(card)=='spade';
                    })>0;//&&player.hasSkill('shizuru_nianli_round');
                    if(name=='tao') return player.countCards('h',{suit:'heart'})>0&&!player.hasSkill('shizuru_nianli_round');
                    return false;
                },
                group: "shizuru_nianli_clear",
                subSkill: {
                    round: {
                        mark: true,
                        intro: {
                            content: "本轮已发动",
                        },
                        sub: true,
                        "_priority": 0,
                        sourceSkill: "念力",
                    },
                    clear: {
                        trigger: {
                            player: "useCardAfter",
                        },
                        lastDo: true,
                        silent: true,
                        filter(event,player){
                            return event.getParent().shizuru_nianli==true;
                        },
                        content(){
                            player.getHistory('useCard').remove(trigger);
                        },
                        sub: true,
                        forced: true,
                        popup: false,
                        "_priority": 1,
                        sourceSkill: "念力",
                    },
                },
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
                "_priority": 0,
            },
            "imps_benzhan": {
                trigger: {
                    global: ["useCard","respond"],
                },
                direct: true,
                filter(event,player){
                    return Array.isArray(event.respondTo)&&event.respondTo[0]!=event.player&&[event.respondTo[0],event.player].includes(player);
                },
                content(){
                    'step 0'
                    event.type=get.type(trigger.card)=='basic';
                    var prompt=event.type?'令一名角色摸四张牌或弃置四张牌':'令一名角色回复2点体力或对其造成2点伤害';
                    player.chooseTarget(get.prompt('shizuru_benzhan'),prompt).set('ai',function(target){
                        var player=_status.event.player;
                        if(_status.event.getParent().type){
                            var att=get.attitude(player,target);
                            if(target.hasSkillTag('nogain')) return -att;
                            if(target.countCards('he')==1&&att<0) att/=2;
                            return Math.abs(att)*(1+0.1*(Math.min(0,5-target.countCards('h'))))
                        }
                        return Math.max(get.recoverEffect(target,player,player),get.damageEffect(target,player,player))
                    });
                    'step 1'
                    if(result.bool){
                        var target=result.targets[0];
                        event.target=target;
                        player.logSkill('shizuru_benzhan',target,'thunder');
                        var trans=get.translation(target);
                        var list;
                        if(event.type){
                            if(!target.countCards('he')) event._result={index:0};
                            else list=['令'+trans+'摸四张牌','令'+trans+'弃置四张牌'];
                        }
                        else{
                            if(target.isHealthy()) event._result={index:1};
                            else list=['令'+trans+'回复2点体力','对'+trans+'造成2点伤害'];
                        }
                        player.chooseControl().set('choiceList',list).set('choice',function(){
                            if(event.type) return (get.attitude(player,target)>0)?0:1;
                            return (get.recoverEffect(target,player,player)>get.damageEffect(target,player,player))?0:1;
                        }()).set('ai',function(){
                            return _status.event.choice;
                        });
                    }
                    else{
                        player.storage.counttrigger[event.name]--;
                        event.finish();
                    }
                    'step 2'
                    player.addExpose(0.2);
                    if(event.type){
                        if(result.index==0) target.draw(4);
                        else target.chooseToDiscard(4,'he',true);
                    }
                    else{
                        if(result.index==0) target.recover(2);
                        else target.damage(2);
                    }
                },
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
                "_priority": 0,
            },
            "imps_fuhan": {
                inherit: "refuhan",
                "Mbaby_characterlist": true,
                content: function(){
                'step 0'
                player.draw(player.storage.fanghun + 3);
                player.removeMark('fanghun',player.storage.fanghun);
                player.awakenSkill("imps_fuhan");
                'step 1'
                if(!_status.characterlist) lib.skill.pingjian.initList();
                var EditList=((!_status.connectMode&&lib.config.extension_活动武将_PingJianName)?lib.config.extension_活动武将_PingJianName:lib.skill.minipingjian.getList()).filter(i=>lib.character[i]);
                var list=EditList.filter(i=>_status.characterlist.includes(i)&&(lib.character[i][1]=='shu'||(get.is.double(i,true)||[]).includes('wu')));
                var players=game.players.concat(game.dead);
                for(var i=0;i<players.length;i++){
                list.remove(players[i].name);
                list.remove(players[i].name1);
                list.remove(players[i].name2);
                }
                list=list.randomGets(2 * Math.max(4,game.countPlayer()));
                var skills=[];
                for(var i of list){
                skills.addArray((lib.character[i][3]||[]).filter(function(skill){
                var info=get.info(skill);
                return info&&!info.zhuSkill&&!info.hiddenSkill&&!info.charlotte;
                }));
                }
                if(!list.length||!skills.length){event.finish();return;}
                if(player.isUnderControl()){
                game.swapPlayerAuto(player);
                }
                var switchToAuto=function(){
                _status.imchoosing=false;
                event._result={
                bool:true,
                skills:skills.randomGets(6),
                };
                if(event.dialog) event.dialog.close();
                if(event.control) event.control.close();
                };
                var chooseButton=function(list,skills){
                var event=_status.event;
                if(!event._result) event._result={};
                event._result.skills=[];
                var rSkill=event._result.skills;
                var dialog=ui.create.dialog('请选择获得至多六个技能',[list,'character'],'hidden');
                event.dialog=dialog;
                var table=document.createElement('div');
                table.classList.add('add-setting');
                table.style.margin='0';
                table.style.width='100%';
                table.style.position='relative';
                for(var i=0;i<skills.length;i++){
                var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
                td.link=skills[i];
                table.appendChild(td);
                td.innerHTML='<span>'+get.translation(skills[i])+'</span>';
                td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
                if(_status.dragged) return;
                if(_status.justdragged) return;
                _status.tempNoButton=true;
                setTimeout(function(){
                _status.tempNoButton=false;
                },500);
                var link=this.link;
                if(!this.classList.contains('bluebg')){
                if(rSkill.length>=6) return;
                rSkill.add(link);
                this.classList.add('bluebg');
                }
                else{
                this.classList.remove('bluebg');
                rSkill.remove(link);
                }
                });
                }
                dialog.content.appendChild(table);
                dialog.add('　　');
                dialog.open();
                
                event.switchToAuto=function(){
                event.dialog.close();
                event.control.close();
                game.resume();
                _status.imchoosing=false;
                };
                event.control=ui.create.control('ok',function(link){
                event.dialog.close();
                event.control.close();
                game.resume();
                _status.imchoosing=false;
                });
                for(var i=0;i<event.dialog.buttons.length;i++){
                event.dialog.buttons[i].classList.add('selectable');
                }
                game.pause();
                game.countChoose();
                };
                if(event.isMine()){
                chooseButton(list,skills);
                }
                else if(event.isOnline()){
                event.player.send(chooseButton,list,skills);
                event.player.wait();
                game.pause();
                }
                else{
                switchToAuto();
                }
                'step 2'
                var map=event.result||result;
                if(map&&map.skills&&map.skills.length) player.addSkills(map.skills);
                'step 3'
                if(player.isMinHp()) player.recover(2);
                },
                derivation: "Mbaby_characterlist_faq",
                audio: "fuhan",
                trigger: {
                    player: "phaseZhunbeiBegin",
                },
                unique: true,
                limited: true,
                skillAnimation: true,
                animationColor: "orange",
                forceunique: true,
                filter: function(event,player){
                    return player.countMark('fanghun')>=0;
                },
                mark: true,
                intro: {
                    content: "limited",
                },
                init: (player, skill) => player.storage[skill] = false,
                "_priority": 0,
                ai: {
                    combo: "refanghun",
                },
            },
            "imps_yuqi": {
                audio: "ext:至尊包:2",
                trigger: {
                    global: "damageEnd",
                },
                init: function(player){
                    if(!player.storage.yuqi) player.storage.yuqi=[1,5,2,2];
                },
                getInfo: function(player){
                    if(!player.storage.yuqi) player.storage.yuqi=[1,5,2,2];
                    return player.storage.yuqi;
                },
                onremove: true,
                usable: 3,
                filter: function(event,player){
                    var list=lib.skill.yuqi.getInfo(player);
                    return event.player.isIn()&&get.distance(player,event.player)<=list[0];
                },
                logTarget: "player",
                content: function(){
                    'step 0'
                    event.list=lib.skill.yuqi.getInfo(player);
                    var cards=get.cards(event.list[1]);
                    event.cards=cards;
                    game.cardsGotoOrdering(cards);
                    var next=player.chooseToMove(true,'隅泣（若对话框显示不完整，可下滑操作）');
                    next.set('list',[
                        ['牌堆顶的牌',cards],
                        ['交给'+get.translation(trigger.player)+'（至少一张'+(event.list[2]>1?('，至多'+get.cnNumber(event.list[2])+'张'):'')+'）'],
                        ['交给自己（至多'+get.cnNumber(event.list[3])+'张）'],
                    ]);
                    next.set('filterMove',function(from,to,moved){
                        var info=lib.skill.yuqi.getInfo(_status.event.player);
                        if(to==1) return moved[1].length<info[2];
                        if(to==2) return moved[2].length<info[3];
                        return true;
                    });
                    next.set('processAI',function(list){
                        var cards=list[0][1].slice(0).sort(function(a,b){
                            return get.value(b,'raw')-get.value(a,'raw');
                        }),player=_status.event.player,target=_status.event.getTrigger().player;
                        var info=lib.skill.yuqi.getInfo(_status.event.player);
                        var cards1=cards.splice(0,Math.min(info[3],cards.length-1));
                        var card2;
                        if(get.attitude(player,target)>0) card2=cards.shift();
                        else card2=cards.pop();
                        return [cards,[card2],cards1];
                    });
                    next.set('filterOk',function(moved){
                        return moved[1].length>=0;
                    });
                    'step 1'
                    if(result.bool){
                        var moved=result.moved;
                        cards.removeArray(moved[1]);
                        cards.removeArray(moved[2]);
                        while(cards.length){
                            ui.cardPile.insertBefore(cards.pop().fix(),ui.cardPile.firstChild);
                        }
                        var list=[[trigger.player,moved[1]]];
                        if(moved[2].length) list.push([player,moved[2]]);
                        game.loseAsync({
                            gain_list:list,
                            giver:player,
                            animate:'gain2',
                        }).setContent('gaincardMultiple');
                    }
                },
                mark: true,
                intro: {
                    content: function(storage,player){
                        var info=lib.skill.yuqi.getInfo(player);
                        return '<div class="text center"><span class=thundertext>蓝色：'+info[0]+'</span>　<span class=firetext>红色：'+info[1]+'</span><br><span class=greentext>绿色：'+info[2]+'</span>　<span class=yellowtext>黄色：'+info[3]+'</span></div>'
                    },
                },
                ai: {
                    threaten: 8.8,
                },
                "_priority": 0,
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
            },
            "imps_shanshen": {
                audio: "ext:至尊包:2",
                trigger: {
                    global: "die",
                },
                direct: true,
                content: function(){
                    'step 0'
                    event.goon=!player.hasAllHistory('sourceDamage',function(evt){
                        return evt.player==trigger.player;
                    });
                    var list=lib.skill.yuqi.getInfo(player);
                    player.chooseControl('<span class=thundertext>蓝色('+list[0]+')</span>','<span class=firetext>红色('+list[1]+')</span>','<span class=greentext>绿色('+list[2]+')</span>','<span class=yellowtext>黄色('+list[3]+')</span>','cancel2').set('prompt',get.prompt('shanshen')).set('prompt2','令〖隅泣〗中的一个数字+2'+(event.goon?'并回复1点体力':'')).set('ai',function(){
                        var player=_status.event.player,info=lib.skill.yuqi.getInfo(player);
                        if(info[0]<info[3]&&game.countPlayer(function(current){
                            return get.distance(player,current)<=info[0];
                        })<Math.min(3,game.countPlayer())) return 0;
                        if(info[3]<info[1]-1) return 3;
                        if(info[1]<5) return 1;
                        if(info[0]<5&&game.hasPlayer(function(current){
                            return current!=player&&get.distance(player,current)>info[0];
                        })) return 0;
                        return 2;
                    });
                    'step 1'
                    if(result.control!='cancel2'){
                        player.logSkill('shanshen',trigger.player);
                        var list=lib.skill.yuqi.getInfo(player);
                        list[result.index]=Math.min(10,list[result.index]+2);
                        game.log(player,'将',result.control,'数字改为','#y'+list[result.index])
                        player.markSkill('yuqi');
                        if(event.goon) player.recover();
                    }
                },
                "_priority": 0,
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
            },
            "imps_xianjing": {
                audio: "ext:至尊包:2",
                trigger: {
                    player: "phaseZhunbeiBegin",
                },
                direct: true,
                content: function(){
                    'step 0'
                    var list=lib.skill.yuqi.getInfo(player);
                    player.chooseControl('<span class=thundertext>蓝色('+list[0]+')</span>','<span class=firetext>红色('+list[1]+')</span>','<span class=greentext>绿色('+list[2]+')</span>','<span class=yellowtext>黄色('+list[3]+')</span>','cancel2').set('prompt',get.prompt('xianjing')).set('prompt2','令〖隅泣〗中的一个数字+1').set('ai',function(){
                        var player=_status.event.player,info=lib.skill.yuqi.getInfo(player);
                        if(info[0]<info[3]&&game.countPlayer(function(current){
                            return get.distance(player,current)<=info[0];
                        })<Math.min(3,game.countPlayer())) return 0;
                        if(info[3]<info[1]-1) return 3;
                        if(info[1]<5) return 1;
                        if(info[0]<5&&game.hasPlayer(function(current){
                            return current!=player&&get.distance(player,current)>info[0];
                        })) return 0;
                        return 2;
                    });
                    'step 1'
                    if(result.control!='cancel2'){
                        player.logSkill('xianjing');
                        var list=lib.skill.yuqi.getInfo(player);
                        list[result.index]=Math.min(10,list[result.index]+1);
                        game.log(player,'将',result.control,'数字改为','#y'+list[result.index])
                        player.markSkill('yuqi');
                        if(player.maxHp - player.getHp() > 1) event.finish();
                    }
                    else event.finish();
                    'step 2'
                    var list=lib.skill.yuqi.getInfo(player);
                    player.chooseControl('<span class=thundertext>蓝色('+list[0]+')</span>','<span class=firetext>红色('+list[1]+')</span>','<span class=greentext>绿色('+list[2]+')</span>','<span class=yellowtext>黄色('+list[3]+')</span>','cancel2').set('prompt','是否令〖隅泣〗中的一个数字+1？').set('ai',function(){
                        var player=_status.event.player,info=lib.skill.yuqi.getInfo(player);
                        if(info[0]<info[3]&&game.countPlayer(function(current){
                            return get.distance(player,current)<=info[0];
                        })<Math.min(3,game.countPlayer())) return 0;
                        if(info[3]<info[1]-1) return 3;
                        if(info[1]<5) return 1;
                        if(info[0]<5&&game.hasPlayer(function(current){
                            return current!=player&&get.distance(player,current)>info[0];
                        })) return 0;
                        return 2;
                    });
                    'step 3'
                    if(result.control!='cancel2'){
                        var list=lib.skill.yuqi.getInfo(player);
                        list[result.index]=Math.min(10,list[result.index]+1);
                        game.log(player,'将',result.control,'数字改为','#y'+list[result.index])
                        player.markSkill('yuqi');
                    }
                },
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
                "_priority": 0,
            },
            "imps_qicai": {
                mod: {
                    canBeDiscarded: function(card){
                        if(get.position(card)=='e') return false;
                    },
                    canBeGained: function(card){
                        if(get.position(card)=='e') return false;
                    },
                },
                "_priority": 0,
            },
            "imps_shenfu": {
                audio: "shenfu",
                trigger: {
                    player: ["phaseEnd","phaseAfter"],
                },
                filter: function(event,player,name){
                if(name=='phaseEnd') return true;
                return player.getHistory('useSkill',function(evt){
                return evt.skill=='minishenfu';
                }).length;
                },
                direct: true,
                content: function(){
                'step 0'
                if(event.triggername=='phaseAfter'){
                player.logSkill('minishenfu');
                player.draw(Math.min(5,player.getHistory('useSkill',function(evt){
                return evt.skill=='minishenfu';
                }).length-1));
                event.finish();
                return;
                }
                event.targets=[];
                event.goto(player.countCards('h')%2==1?1:4);
                'step 1'
                player.chooseTarget(get.prompt('minishenfu'),'对一名其他角色造成2点雷属性伤害',function(card,player,target){
                return target!=player;
                }).set('ai',function(target){
                var player=_status.event.player;
                return get.damageEffect(target,player,player,'thunder')*(target.hp==1?2:1);
                });
                'step 2'
                if(result.bool){
                var target=result.targets[0];
                event.target=target;
                targets.push(target);
                player.logSkill('minishenfu',target,'thunder');
                target.damage(2,'thunder');
                }
                else event.finish();
                'step 3'
                if(target.isDead()) event.goto(1);
                else if(target.getHp()<=1) event.goto(1);
                else event.finish();
                'step 4'
                if(!game.hasPlayer(function(target){
                return !event.targets.includes(target);
                })){event.finish();return;}
                player.chooseTarget(get.prompt('minishenfu'),'令一名角色摸2张牌或弃置其2张手牌',function(card,player,target){
                return true
                //!_status.event.getParent().targets.includes(target);
                }).set('ai',function(target){
                var att=get.attitude(_status.event.player,target);
                var delta=target.hp-target.countCards('h');
                if(Math.abs(delta)==1&&get.sgn(delta)==get.sgn(att)) return 3*Math.abs(att);
                if(att>0||target.countCards('h')>0) return Math.abs(att);
                return 0;
                });
                'step 5'
                if(result.bool){
                var target=result.targets[0];
                event.target=target;
                player.logSkill('minishenfu',target,'wood');
                targets.push(target);
                if(target.countCards('h')==0) event._result={index:0};
                else player.chooseControl('摸2张牌','弃置2张牌').set('prompt','选择一项令'+get.translation(target)+'执行…').set('goon',get.attitude(player,target)>0?0:1).set('ai',()=>_status.event.goon);
                }
                else event.finish();
                'step 6'
                if(result.index==0) target.draw(2);
                else {
                    player.discardPlayerCard(target,'he',true);
                    player.discardPlayerCard(target,'he',true);
                }
                'step 7'
                if(Math.abs(target.hp - target.countCards('h'))<=1) event.goto(4);
                },
                ai: {
                    expose: 0.25,
                },
                "_priority": 0,
            },
            "imps_qiwu": {
                audio: "ext:至尊包:true",
                trigger: {
                    player: "useCard",
                },
                direct: true,
                filter: function (event, player) {
                    if (get.suit(event.card) == "club") {
                        return game.hasPlayer(function (current) {
                            return current.hujia <= 5;
                        });
                    }
                    return false;
                },
                content: function () {
                    "step 0";
                    var noneed =
                        trigger.card.name == "tao" &&
                        trigger.targets[0] == player &&
                        player.hp == player.maxHp - 1;
                    player.chooseTarget(get.prompt("boss_qiwu"), function (card, player, target) {
                        return target.hujia <= 5;
                    }).ai = function (target) {
                        var num = get.attitude(player, target);
                        if (num > 0) {
                            if (noneed && player == target) {
                                num = 0.5;
                            } else if (target.hp == 1) {
                                num += 3;
                            } else if (target.hp == 2) {
                                num += 1;
                            }
                        }
                        return num;
                    };
                    "step 1";
                    if (result.bool) {
                        player.logSkill("qiwu", result.targets);
                        if (result.targets[0].isDamaged()){
                            result.targets[0].recover();
                        }
                        else {
                            result.targets[0].changeHujia(1);
                        }
                    }
                },
                ai: {
                    expose: 0.3,
                    threaten: 1.5,
                },
                "_priority": 0,
            },
            "imps_jujian": {
                audio: "xinjujian",
                trigger: {
                    global: ["phaseZhunbeiBegin","phaseEnd"],
                },
                filter: function (event, player) {
                    return player.countCards('he') > 0;
                },
                direct: true,
                content: function () {
                    'step 0'
                    player.chooseCardTarget({
                        filterTarget: true,
                        filterCard: function (card, player) {
                            return lib.filter.cardDiscardable(card, player);
                        },
                        ai1: function (card) {
                            if (get.tag(card, 'damage') && get.type(card) == 'trick') {
                                return 20;
                            }
                            return 9 - get.value(card);
                        },
                        ai2: function (target) {
                            var att = get.attitude(_status.event.player, target);
                            if (att > 0) {
                                if (target.isTurnedOver()) att += 3;
                                if (target.hp == 1) att += 3;
                            }
                            return att;
                        },
                        position: 'he',
                        prompt: get.prompt2('minijujian')
                    });
                    'step 1'
                    if (result.bool) {
                        var target = result.targets[0];
                        event.target = target;
                        player.logSkill('minijujian', target);
                        player.discard(result.cards);
                        if (target.hp == target.maxHp &&
                            !target.isTurnedOver() &&
                            !target.isLinked()) {
                            target.draw(3);
                            event.finish();
                        }
                        else {
                            var controls = ['draw_card'];
                            if (target.hp < target.maxHp) {
                                controls.push('recover_hp');
                            }
                            if (target.isLinked() | target.isTurnedOver()) {
                                controls.push('reset_character');
                            }
                            target.chooseControl(controls).ai = function () {
                                if (target.isTurnedOver()) {
                                    return 'reset_character';
                                }
                                else if (target.hp == 1 && target.maxHp > 2) {
                                    return 'recover_hp';
                                }
                                else if (target.hp == 2 && target.maxHp > 2 && target.countCards('h') > 1) {
                                    return 'recover_hp';
                                }
                                else {
                                    return 'draw_card';
                                }
                            }
                        }
                    }
                    else event.finish();
                    'step 2'
                    event.control = result.control;
                    switch (event.control) {
                        case 'recover_hp': event.target.recover(); event.finish(); break;
                        case 'draw_card': event.target.draw(3); event.finish(); break;
                        case 'reset_character': if (event.target.isTurnedOver()) event.target.turnOver(); break;
                    }
                    'step 3'
                    if (event.control == 'reset_character' && event.target.isLinked()) event.target.link();
                },
                "_priority": 0,
            },
            "imps_fengzi": {
                audio: "ext:至尊包:2",
                trigger: {
                    player: "useCard",
                },
                direct: true,
                usable: 3,
                filter: function (event, player) {
                    if (event.olfengzi_buff || !event.targets.length || player.hasSkill("olfengzi_buff")) return false;
                    var type = get.type(event.card, null, false);
                    if (type != "basic" && type != "trick") return false;
                    return player.hasCard(function (i) {
                        if (_status.connectMode) return true;
                        return get.type2(i, player) == type;
                    }, "h");
                },
                content: function () {
                    "step 0";
                    if (player != game.me && !player.isUnderControl() && !player.isOnline()) game.delayx();
                    var type = get.type(trigger.card, null, false);
                    player
                        .chooseToDiscard("h", get.prompt("olfengzi"), "弃置一张" + get.translation(type) + "牌，令" + get.translation(trigger.card) + "结算三次", function (card, player) {
                            return get.type2(card, player) == _status.event.type;
                        })
                        .set("type", type)
                        .set("ai", function (card) {
                            var player = _status.event.player;
                            var trigger = _status.event.getTrigger();
                            if (trigger.card.name == "tiesuo") return 0;
                            var num = 0;
                            for (var i of trigger.targets) num += get.effect(i, trigger.card, player, player);
                            if (num <= 0) return 0;
                            return 7 - get.value(card);
                        }).logSkill = "olfengzi";
                    "step 1";
                    if (result.bool) {
                        trigger.effectCount++;
                    } else player.storage.counttrigger.olfengzi--;
                    if (result.bool) {
                        trigger.effectCount++;
                    } else player.storage.counttrigger.olfengzi--;
                },
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
                "_priority": 0,
            },
            "imps_jizhan": {
                audio: "ext:至尊包:2",
                trigger: {
                    player: "phaseDrawBegin1",
                },
                filter: function (event, player) {
                    return !event.numFixed;
                },
                content: function () {
                    "step 0";
                    trigger.changeToZero();
                    var card = get.cards()[0];
                    game.cardsGotoOrdering(card);
                    event.cards = [card];
                    event.num = get.number(card, false);
                    player.showCards(card, get.translation(player) + "发动了【吉占】");
                    "step 1";
                    var str = get.strNumber(num);
                    player
                        .chooseControl("大于" + str, "小于" + str, "cancel2")
                        .set("prompt", "吉占：猜测下一张牌的点数")
                        .set("choice", num < 7 ? 0 : 1)
                        .set("ai", () => _status.event.choice);
                    "step 2";
                    var card = get.cards()[0];
                    game.cardsGotoOrdering(card);
                    event.cards.push(card);
                    var num = get.number(card, false);
                    if ((num >= event.num - 2 && result.index == 0) || (num <= event.num + 2 && result.index == 1)) {
                        event.num = num;
                        event.goto(1);
                    }
                    player.showCards(card);
                    "step 3";
                    player.gain(cards, "gain2");
                    if(cards.length <=5){
                        event.num = num;
                        event.goto(1);
                    };
                },
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
                "_priority": 0,
            },
            "imps_yujie": {
                audio: "ext:至尊包:2",
                trigger: {
                    global: ["gameStart","roundStart"],
                },
                filter: function (event, player, name) {
                    if((name == 'roundStart') && (game.roundNumber < 2)) return false;
                    return true;
                },
                direct: true,
                content() {
                    "step 0";
                    player.chooseTarget(get.prompt2("shiki_omusubi"), lib.filter.notMe).set("ai", function (target) {
                        var player = _status.event.player;
                        if (player.isHealthy()) return 0;
                        if (player.hp < 3 && player.getDamagedHp() < 2) return 0;
                        var list = [];
                        if (lib.character[target.name]) list.addArray(lib.character[target.name][3]);
                        if (lib.character[target.name1]) list.addArray(lib.character[target.name1][3]);
                        if (lib.character[target.name2]) list.addArray(lib.character[target.name2][3]);
                        list = list.filter(function (i) {
                            return !player.hasSkill(i);
                        });
                        if (!list.length) return 0;
                        return 1 + Math.random();
                    });
                    "step 1";
                    if (result.bool) {
                        var target = result.targets[0];
                        player.logSkill("shiki_omusubi", target);
                        player.loseMaxHp();
                        var list = [];
                        if (lib.character[target.name]) list.addArray(lib.character[target.name][3]);
                        if (lib.character[target.name1]) list.addArray(lib.character[target.name1][3]);
                        if (lib.character[target.name2]) list.addArray(lib.character[target.name2][3]);
                        player.addSkills(list);
                        game.broadcastAll(function (list) {
                            lib.character.key_shiki[3].addArray(list);
                            game.expandSkills(list);
                            for (var i of list) {
                                var info = lib.skill[i];
                                if (!info) continue;
                                if (!info.audioname2) info.audioname2 = {};
                                info.audioname2.key_shiki = "shiki_omusubi";
                            }
                        }, list);
                    }
                },
                "_priority": 0,
            },
            "imps_yangfan": {
                trigger: {
                    player: ["loseAfter","enterGame"],
                    global: ["equipAfter","addJudgeAfter","phaseBefore","gainAfter","loseAsyncAfter","addToExpansionAfter"],
                },
                forced: true,
                filter(event, player) {
                    if (typeof event.getl != "function") return event.name != "phase" || game.phaseNumber == 0;
                    var evt = event.getl(player);
                    return evt && evt.player == player && evt.es && evt.es.length;
                },
                content() {
                    if (trigger.getl) player.draw(3 * trigger.getl(player).es.length);
                    else {
                        player.equip(game.createCard2("kamome_suitcase", "spade", 1));
                        player.equip(game.createCard2("snjs_card_qicaishenlu", "diamond", 3));
                        player.equip(game.createCard2("snjs_card_benleixidian", "club", 2));
                        player.equip(game.createCard2("qimenbagua", "spade", 4));
                        player.equip(game.createCard2("snjs_card_guilongzhanyuedao", "heart", 5));
                    }
                },
                ai: {
                    noe: true,
                    reverseEquip: true,
                    effect: {
                        target(card, player, target, current) {
                            if (get.type(card) == "equip" && !get.cardtag(card, "gifts")) return [1, 3];
                        },
                    },
                },
                "_priority": 0,
                "audioname2": {
                    "key_shiki": "shiki_omusubi",
                },
            },
            "imps_jieban": {
                trigger: {
                    player: "damageEnd",
                    source: "damageSource",
                },
                zhuanhuanji: true,
                marktext: "☯",
                mark: true,
                intro: {
                    content(storage, player) {
                        return "转换技。每回合限一次，当你受到或造成伤害后，" + (!storage ? "你可将五张牌交给一名其他角色，然后其交给你五张牌并获得一点护甲。" : "你可将五张牌交给一名其他角色，然后其交给你五张牌，你获得一点护甲。");
                    },
                },
                filter(event, player) {
                    var num = player.storage.imps_jieban ? 1 : 2;
                    return player.countCards("he") >= num && !player.hasSkill("imps_jieban_phase");
                },
                async cost(event, trigger, player) {
                    event.num = player.storage.imps_jieban ? 1 : 2;
                    event.result = await player
                        .chooseCardTarget({
                            position: "he",
                            filterCard: true,
                            filterTarget: lib.filter.notMe,
                            selectCard: 5,
                            prompt: get.prompt("imps_jieban"),
                            prompt2: event.num == 2 ? "将五张牌交给一名其他角色，然后其交给你五张牌。" : "将五张牌交给一名其他角色，然后其交给你五张牌。",
                            ai1(card) {
                                if (card.name == "du") return 20;
                                var val = get.value(card);
                                var player = _status.event.player;
                                if (get.position(card) == "e") {
                                    if (val <= 0) return 10;
                                    return 10 / val;
                                }
                                return 6 - val;
                            },
                            ai2(target) {
                                var player = _status.event.player;
                                var att = get.attitude(player, target);
                                if (ui.selected.cards[0].name == "du") return -2 * att;
                                if (att > 0) return 1.5 * att;
                                var num = get.select(_status.event.selectCard)[1];
                                if (att < 0 && num == 1) return -0.7 * att;
                                return att;
                            },
                        })
                        .forResult();
                },
                content() {
                    "step 0";
                    event.num = player.storage.imps_jieban ? 1 : 2;
                    var target = targets[0];
                    event.target = target;
                    player.addTempSkill("imps_jieban_phase");
                    player.give(cards, target);
                    player.changeZhuanhuanji("imps_jieban");
                    "step 1";
                    var num = 3 - event.num;
                    var hs = target.getCards("he");
                    if (hs.length) {
                        if (hs.length <= num) event._result = { bool: true, cards: hs };
                        else {
                            target.chooseCard("he", true, "交给" + get.translation(player) + "五张牌", 5).set("ai", function (card) {
                                var player = _status.event.player;
                                var target = _status.event.getParent().player;
                                if (get.attitude(player, target) > 0) {
                                    if (!target.hasShan() && card.name == "shan") return 10;
                                    if (get.type(card) == "equip" && !get.cardtag(card, "gifts") && target.hasUseTarget(card)) return 10 - get.value(card);
                                    return 6 - get.value(card);
                                }
                                return -get.value(card);
                            });
                        }
                    } else event.finish();
                    "step 2";
                    target.give(result.cards, player);
                    for(let i = 0; i < 5; i++){
                        target.chooseToUse(
                            function (card) {
                                if(!lib.filter.cardEnabled(card, _status.event.player, _status.event)) return false;
                                return get.type(card) == "equip";
                            },
                            "结伴：是否使用一张装备牌？第" + (i+1) + "张",
                        );
                    }
                    "step 3";
                    if(player.storage.imps_jieban){
                        target.changeHujia(1);
                    } else {
                        player.changeHujia(1);
                    }
                },
                "imps_jieban_phase": {
                    charlotte: true,
                },
                "_priority": 0,
            },
            "imps_hengwu": {
                audio: "hengwu",
                mod: {
                    aiOrder: (player, card, num) => {
                        if (num > 0 && get.tag(card, "draw") && ui.cardPile.childNodes.length + ui.discardPile.childNodes.length < 20) return 0;
                    },
                    aiValue: (player, card, num) => {
                        if (num > 0 && card.name === "zhuge") return 20;
                    },
                    aiUseful: (player, card, num) => {
                        if (num > 0 && card.name === "zhuge") return 10;
                    },
                },
                trigger: {
                    player: ["useCard","respond"],
                },
                direct: true,
                locked: false,
                filter(event, player) {
                    return game.hasPlayer(i => i.countCards("ej", cardx => get.type(cardx) == "equip" && get.color(event.card) == get.color(cardx)));
                },
                content() {
                    "step 0";
                    var color = get.color(trigger.card),
                        extra = game
                            .filterPlayer()
                            .map(i =>
                                i.countCards("ej", cardx => {
                                    return get.type(cardx) == "equip" && get.color(trigger.card) == get.color(cardx);
                                })
                            )
                            .reduce((p, c) => p + c);
                    var prompt2 = "弃置任意张" + get.translation(color) + "手牌，然后摸X张牌（X为你弃置的牌数+" + extra + "）";
                    player
                        .chooseToDiscard("h", [1, player.countCards("h", { color: color })], { color: color })
                        .set("prompt", get.prompt("pshengwu"))
                        .set("prompt2", prompt2)
                        .set("ai", card => {
                            if (_status.event.tie) return 0;
                            let player = _status.event.player;
                            if (_status.event.goon) return 12 - get.value(card);
                            if (player == _status.currentPhase) {
                                if (["shan", "caochuan", "tao", "wuxie"].includes(card.name)) return 8 - get.value(card);
                                return 6 - get.value(card);
                            }
                            return 5.5 - get.value(card);
                        })
                        .set("goon", player.countCards("h", { color: color }) == 1)
                        .set("tie", extra > ui.cardPile.childNodes.length + ui.discardPile.childNodes.length)
                        .set("logSkill", "pshengwu");
                    "step 1";
                    if (result.bool) {
                        var num = result.cards.length;
                        player.draw(
                            num +
                            game
                                .filterPlayer()
                                .map(i => i.countCards("ej", cardx => get.type(cardx) == "equip" && get.color(trigger.card) == get.color(cardx)))
                                .reduce((p, c) => p + c)
                        );
                    }
                },
                ai: {
                    threaten: 100,
                    reverseEquip: true,
                    effect: {
                        player_use(card, player, target) {
                            if (typeof card !== "object") return;
                            let color = get.color(card);
                            if (
                                !lib.color.includes(color) ||
                                player.hasCard(function (i) {
                                    return get.color(i, player) == color;
                                }, "h")
                            )
                                return;
                            return [
                                1,
                                game.countPlayer(current => {
                                    return current.countCards("e", card => {
                                        return get.color(card, current) == color;
                                    });
                                }),
                            ];
                        },
                        target(card, player, target) {
                            if (
                                card.name === "sha" &&
                                !player.hasSkillTag(
                                    "directHit_ai",
                                    true,
                                    {
                                        target: target,
                                        card: card,
                                    },
                                    true
                                ) &&
                                game.hasPlayer(current => {
                                    return current.hasCard(cardx => {
                                        return get.subtype(cardx) === "equip3";
                                    }, "e");
                                })
                            )
                                return [0, -0.5];
                        },
                    },
                },
                "_priority": 0,
            },
            "imps_shenpao": {
                trigger: {
                    global: "phaseBefore",
                    player: ["phaseZhunbeiBegin","enterGame"],
                },
                filter(event, player) {
                    if (event.name == 'phase' && game.phaseNumber > 0) return false;
                    if (player.getEquip('impc_railgun')) {
                        return game.hasPlayer(current => {
                            return current != player && current.countDiscardableCards(player, 'he') > 0;
                        });
                    }
                    return player.hasEquipableSlot(4);
                },
                frequent: true,
                async cost(event, trigger, player) {
                    if (!player.getEquip('impc_railgun')) {
                        event.result = await player.chooseBool(get.prompt('imps_shenpao'), '装备一张【高斯轨道炮】').set('frequentSkill', 'imps_shenpao').forResult();
                    }
                },
                content() {
                    //"step 0";
                    var list = [];
                    for (var i = 1; i < 6; i++) {
                        for (var j = 0; j < player.countDisabledSlot(i); j++) {
                            list.push(i);
                        }
                    }
                    if (list.length > 0) player.enableEquip(list);
                    const card = game.createCard('impc_railgun', 'diamond', 13);
                    player.$gain2(card);
                    game.delayx();
                    player.equip(card);
                },
                "_priority": 0,
            },
        },
        translate: {
            "impc_railgun_skill": "高斯轨道炮",
			
			
            "imps_ranji": "燃己",
            "imps_ranji_info": "限定技，结束阶段，若你本回合使用过牌的阶段数大于等于体力值减一/小于等于体力值加一，你可以获得技能〖困奋〗/〖诈降〗（同时满足则都获得，以此法获得的〖困奋〗直接修改为非锁定技）。若如此做，你将手牌数调整至手牌上限或将体力值回复至体力上限，然后你不能回复体力直到你杀死角色。",
            "imps_nianli": "念力",
            "imps_nianli_info": "一回合限三次，你可以展示一张♦/♣/♥/♠手牌，然后视为使用一张不计入次数限制和记录的雷【杀】/【闪】/【桃】/【无懈可击】。",
            "imps_benzhan": "奔战",
            "imps_benzhan_info": "当你使用或打出牌响应其他角色，或其他角色使用或打出牌响应你后，若此牌为：基本牌，你可令一名角色弃置四张牌或令一名角色摸四张牌；非基本牌，你可对一名角色造成2点伤害或令一名其他角色回复2点体力。",
            "imps_fuhan": "扶汉",
            "imps_fuhan_info": "限定技，回合开始时，你可以移去所有\"梅影\"标记并摸等量+3的牌，然后从欢杀将池中的随机2X张存在于武将牌堆的蜀势力武将牌中选择并获得至多六个技能（隐匿技、主公技除外）。若此时你是体力值最低的角色，你回复2点体力（X为场上角色数，且X至少为4）。",
            "imps_yuqi": "隅泣",
            "imps_yuqi_info": "每回合限三次。当有角色受到伤害后，若你至其的距离不大于<span class=thundertext>1</span>，则你可以观看牌堆顶的<span class=firetext>5</span>张牌。你将其中至多<span class=greentext>2</span>张牌交给受伤角色，然后可以获得剩余牌中的至多<span class=yellowtext>2</span>张牌，并将其余牌以原顺序放回牌堆顶。（所有具有颜色的数字至多为10）",
            "imps_shanshen": "善身",
            "imps_shanshen_info": "当有角色死亡时，你可令你的〖隅泣〗中的一个具有颜色的数字+2。然后若你未对该角色造成过伤害，则你回复1点体力。",
            "imps_xianjing": "娴静",
            "imps_xianjing_info": "准备阶段，你可令你的〖隅泣〗中的一个具有颜色的数字+1。若你的已损失体力值不大于1，则你可以重复一次此流程。",
            "imps_qicai": "奇才",
            "imps_qicai_info": "锁定技，你装备区内的牌不能被其他角色弃置和获得。",
            "imps_shenfu": "神赋",
            "imps_shenfu_info": "①回合结束时，若你的手牌数为：奇数，你可对一名其他角色造成2点雷属性伤害，若其死亡，你可重复此流程；偶数，你可选择一名角色，你令其摸2张牌或弃置其2张牌，若其手牌数等与体力值之差不大于1，你可重复此流程。②回合结束后，你摸X张牌（X为你本回合发动〖神赋〗的次数且至多为5）。",
            "imps_qiwu": "栖梧",
            "imps_qiwu_info": "每当你使用一张梅花牌，你可以指定一名护甲不超过5点的角色。若其已受伤，其回复1点体力，否则其获得一点护甲。。",
            "imps_jujian": "举荐",
            "imps_jujian_info": "任意一名角色的准备阶段和结束阶段，你可以弃置一张牌并选择一名角色，令其选择一项：1.摸三张牌；2.回复1点体力；3.将其武将牌翻转至正面朝上并重置之。",
            "imps_fengzi": "丰姿",
            "imps_fengzi_info": "每回合限三次。当你使用有目标的基本牌或普通锦囊牌时，你可弃置一张与此牌类型相同的牌，然后令此牌结算三次。",
            "imps_jizhan": "吉占",
            "imps_jizhan_info": "摸牌阶段开始时，你可以放弃摸牌。你亮出牌堆顶的一张牌，并猜测牌堆顶的下一张牌点数大于或小于此牌。若你猜对(误差不超过5即可)或将获得的牌数不超过3，你可继续重复此流程。然后你获得以此法展示的所有牌。",
            "imps_yujie": "御结",
            "imps_yujie_info": "游戏开始和第二轮后的每轮游戏开始时，你可以减1点体力上限，然后将一名其他角色武将牌上的技能加入到你的武将牌上。",
            "imps_yangfan": "扬帆",
            "imps_yangfan_info": "锁定技，游戏开始时，你将依次将一张【旅行箱】【七彩神鹿】【奔雷袭电】【奇门八卦】【鬼龙斩月刀】置入你的装备区。当你失去装备区内的一张牌后，你摸三张牌。",
            "imps_jieban": "结伴",
            "imps_jieban_info": "转换技。每回合限一次，当你受到或造成伤害后，你可将五张牌交给一名其他角色，然后其交给你五张牌，其可依次使用五张装备牌，最后（阴：其 / 阳：你）增加一点护甲。",
            "imps_hengwu": "横骛",
            "imps_hengwu_info": "当你使用或打出牌时，若场上有该颜色的装备牌，你可以弃置任意张该颜色的手牌，然后摸X张牌（X为你弃置的牌数与场上与此牌颜色相同的装备牌数之和）。",
            "imps_shenpao": "神炮",
            "imps_shenpao_info": "准备阶段，若你武器栏已废除，你恢复之。若你未装备【高斯轨道炮】，你可以装备之。",
        },
    },
    intro: "",
    author: "Diaz",
    diskURL: "",
    forumURL: "",
    version: "1.0",
},files:{"character":["imp_zhaoxiang.jpg","imp_zhangjiao.jpg","imp_shiki.jpg","imp_shizuru.jpg","imp_zhangfen.jpg","imp_zhenji.jpg","imp_saimiuer.jpg","imp_illya.jpg","imp_guozhao.jpg","imp_caojinyu.jpg","imp_jiangwei.jpg","imp_kamome.jpg","imp_shiori.jpg","imp_xintianbuzhi.jpg","imp_wolier.jpg"],"card":["impc_railgun.png","impc_KochiyaReidaisai.png"],"skill":[],"audio":[]}}
});